<?php

namespace App\Services\Netease;

class ChatRoomServices extends BaseServices
{
    /**
     * 聊天室-创建聊天室
     * @param  $creator [聊天室属主的账号accid]
     * @param  $name    聊天室名称，长度限制128个字符
     * @return $result      [返回array数组对象]
     */
    public function createChatRoom($creator, $name)
    {
        if (empty($creator) || empty($name)) {
            return false;
        }
        $url = $this->url . '/chatroom/create.action';
        $data = array(
            'creator' => $creator,
            'name' => $name,
        );
        $result = $this->postDataCurl($url, $data);
        return resultNeteaseInfo($result);
    }

    /**
     * 聊天室-查询聊天室信息
     * @param  $roomid [聊天室id]
     * @param  $needOnlineUserCount    是否需要返回在线人数，true或false，默认false
     * @return $result      [返回array数组对象]
     */
    public function getChatRoom($roomid, $needOnlineUserCount=true)
    {
        if (empty($roomid)) {
            return false;
        }
        $url = $this->url . '/chatroom/create.action';
        $data = array(
            'roomid' => $roomid,
            'needOnlineUserCount' => $needOnlineUserCount,
        );
        $result = $this->postDataCurl($url, $data);
        return resultNeteaseInfo($result);
    }

}
